using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Ezio.Model;

namespace Ezio.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [XmlSerializerFormat]
    public class SalidasBodegasService : BaseService
    {

        [WebInvoke(UriTemplate = "Create", Method = "POST")]
        public bool Create(SalidasBodegas SalidaBodega)
        {
            Provider.AddToSalidasBodegas(SalidaBodega);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "CreateMassive", Method = "POST")]
        public bool Create(ArrayList ListSalidaBodega)
        {
            ListSalidaBodega.ToArray().ToList().ForEach(t => Provider.AddToSalidasBodegas((SalidasBodegas)t));
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "GetAll", Method = "POST")]
        public ArrayList GetAll()
        {
            return new ArrayList(Provider.SalidasBodegas.ToList());
        }

        [WebInvoke(UriTemplate = "GetById", Method = "POST")]
        public SalidasBodegas GetById(int Id)
        {
            return Provider.SalidasBodegas.Single(i => i.IdSalidaBodega == Id);
        }

        [WebInvoke(UriTemplate = "Update", Method = "POST")]
        public bool Update(SalidasBodegas SalidaBodega)
        {
            SalidasBodegas miSalidaBodega = Provider.SalidasBodegas.Where(t => t.IdSalidaBodega == SalidaBodega.IdSalidaBodega).First();
            miSalidaBodega.Copy(SalidaBodega);
            return Provider.TrySaveChanges();
        }

    }
}